package com.songlanyun.modules.usergains.controller.api;

import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.account.controller.common.AbstractApiController;
import com.songlanyun.modules.user.controller.AbstractController;
import com.songlanyun.modules.usergains.entity.UserOrderGains;
import com.songlanyun.modules.usergains.model.AirdropStatisticsVo;
import com.songlanyun.modules.usergains.model.UserOrderGainsStatisticsVo;
import com.songlanyun.modules.usergains.service.UserOrderGainsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;


/**
 * 会员分佣所得表
 *
 * @author wuchao
 * @email sunlightcs@gmail.com
 * @date 2020-12-22 15:21:52
 */
@RestController
@RequestMapping("api/userordergains")
public class UserOrderGainsApiController extends AbstractApiController {
    @Autowired
    private UserOrderGainsService userOrderGainsService;

    /**
     * 会员分页查看分销订单
     *  * mobile 分佣人手机号,可以不给
     *      * order_code 订单号,可以不给
     *      * status 订单状态,可以不给(1未完成，2已完成，未结算，3已结算)
     *      * start_date 开始日期，可以不给(格式2020-12-10)
     *      * end_date 结束日期，可以不给(格式2020-12-10)
     *      * page
     *      * limit
     */
    @GetMapping("/pages")
    //@RequiresPermissions("usergains:distributionuserordergains:list")
    public R page(@RequestParam Map<String, Object> params) {
        params.put("user_id", getUserId(true));
        PageUtils page = userOrderGainsService.queryPage(params);

        return R.ok().put("page", page);
    }

    @GetMapping("/slim-statistics")
    public R slimStatistics() {

        UserOrderGainsStatisticsVo vo = userOrderGainsService.slimStatistics(getUserId(true));

        return R.ok().put("data", vo);
    }

    @GetMapping("/statistics")
    public R statistics() {

        UserOrderGainsStatisticsVo vo = userOrderGainsService.statistics(getUserId(true));

        return R.ok().put("data", vo);
    }


    /**
     *
     * @return
     */
    @GetMapping("/airdropStatistics")
    //@RequiresPermissions("usergains:distributionuserordergains:list")
    public R airdropStatistics() {
        AirdropStatisticsVo vo = userOrderGainsService.airdropStatistics();
        return R.ok().put("data", vo);
    }

}
